<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>css最新布局方案Grid Flex的兄弟</title>
    <style>
        .container {
            display: grid;
            /*启动网格布局 九宫格*/
            justify-content: center;
            height: 100vh;
            align-content: center;
            grid-template-columns: repeat(3, 100px);
            grid-template-rows: repeat(auto-fill, 200px);
        }
        /* .box {
            background-color: green;
        }
        
        .box:nth-child(odd) {
            background-color: pink;
        }
        
        .box:nth-child(even) {
            background-color: red;
        }
        
        .box:nth-child(1) {
            background-color: red;
        }
        
        .box:nth-child(2) {
            background-color: green;
        }
        
        .box:nth-child(3) {
            background-color: yellow;
        }
        
        .box:nth-child(4) {
            background-color: blue;
        }
        
        .box:nth-child(5) {
            background-color: pink;
        }
        
        .box:nth-child(6) {
            background-color: gray;
        }
        
        .box:nth-child(7) {
            background-color: lightgray;
        }
        
        .box:nth-child(8) {
            background-color: orange;
        }
        
        .box:nth-child(9) {
            background-color: lightcyan;
        } */
    </style>
    <link rel="stylesheet" href="grid.css">
</head>

<body>
    <!-- 二维布局,row column  -->
    <div class="container">
        <div class="box">1</div>
        <div class="box">2</div>
        <div class="box">3</div>
        <div class="box">4</div>
        <div class="box">5</div>
        <div class="box">6</div>
        <div class="box">7</div>
        <div class="box">8</div>
        <div class="box">9</div>
        <div class="box">10</div>
        <div class="box">11</div>
        <div class="box">12</div>
        <div class="box">13</div>
    </div>
    <script>
        // const boxes = document.querySelectorAll('.box');
        // let i = 1;
        // for (let box of boxes) {
        //     i++;
        //     box.style.backgroundColor = `rgba(${i*20},${i*10},${i*5})`
        // }
    </script>
</body>

</html>